package cn.wlinker.driver.bacnet.domain;

import lombok.*;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Objects;

/**
 * bacnet点位对象
 *
 * @author gxsjx
 * @version 1.0
 * @date 2022/9/18
 * Copyright © wlinker.cn
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class BacnetObject extends HashMap<String, String> implements Serializable {

    /**KEY，注意：大多数情况下有的系统一个KEY代表一个监控项，有的厂家，例如电表一个KEY代表一个电表设备*/
    private String objectIdentifier;

    /**名称*/
    private String objectName;

    /**数值*/
    private String presentValue;

    /**活动文本*/
    private String activeText;

    /**非活动文本*/
    private String inactiveText;

    /**单位*/
    private String units;

    /**描述*/
    private String description;


    /**
     * 设备id
     */
    private String remoteId;

    /**
     * 远端id:bacnet_设备id_属性id
     */
    private String originalId;

    /**
     * 状态文本
     */
    private String stateText;

    @Override
    public int hashCode() {
        return Objects.hash(objectIdentifier);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        } else if (obj == null) {
            return false;
        } else if (this.getClass() != obj.getClass()) {
            return false;
        } else {
            BacnetObject other = (BacnetObject)obj;
            if (this.objectIdentifier == null) {
                return other.objectIdentifier == null;
            } else{
                return this.objectIdentifier.equals(other.objectIdentifier);
            }
        }
    }

}